package com.j.lemon.learn.pulsar;

import org.apache.pulsar.client.api.Producer;
import org.apache.pulsar.client.api.PulsarClient;
import org.apache.pulsar.client.api.PulsarClientException;
import org.apache.pulsar.client.api.Schema;

/**
 * @Author lijunjun
 * @Date 2020-07-06 15:41
 * @Description
 */
public class Sender2 {
    public static void main(String[] args) throws PulsarClientException, InterruptedException {
        PulsarClient pulsarClient = PulsarUtils.getClient();
        Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
                .topic("persistent://4a/audit/subscriptionType-dev1")
                .producerName("ljj2")
                .create();
        String msg = "<88>charGate:optTime=20200915124255,sessionId=1600144965893,sessionIdPa=,pracct=cf_zlf,slacct=ossuser,srcIP=134.178.19.48,srcMAC=,srcHost=,dstIP=134.175.64.37,dstPort=21,dstName=,dstId=,dstHost=,oper=MDTM 20200915024928 /HOME/OSSUSER/USEREDIT.JSP,operProtocol=ftp,operDir=,result=0,despCmd=MDTM 20200915024928= /HOME/OSSUSER/USEREDIT,JSP,extJson={\"operResp\":\"t1 t2\"},errMsg=,workOrder=,workOrderType=,fromSys=HOST";
//        String msg = "<85>tacplus: optTime=20200918105122,sessionId=1600397482,sessionIdPa=,pracct=UNI_config,slacct=,srcIP=203.119.113.151,srcMAC=,srcHost=,dstIP=61.187.97.72,dstPort=49,dstName=,dstId=,dstHost=,oper=cmd,operProtocol=ip,operDir=,result=0,despCmd=dis logb level 2  | include \"Sep 17.*%%01[^S][^O][^C][^K][^E][^T]\",errMsg=,workOrder=,workOrderType=,fromSys=HOST";
//        String msg = "{\"RESOURCE_KIND\":\"2\",\"SESSION_BEGIN_TIME\":\"2020-09-17 22:22:21\",\"CLIENT_NETWORK_ADDRESS\":\"10.255.185.32\",\"BANK_APPROVE\":\"##131419\",\"OPERATE_DIR\":\"//\",\"SUB_ACCOUNT_ID\":\"2458294\",\"MAIN_ACCOUNT_NAME\":\"kd_tanyf\",\"OPERATE_TIME\":\"2020-09-17 22:37:41\",\"PROVINCE_SOURCE_ID\":\"1\",\"OBJECT_ID\":\"131419\",\"OPERATE_CONTENT\":\"SSH_FXP_WRITE /home/kd_tanyf/AnHui/Reflection/anhui_reflection_gpu_v3.tar.gzad\",\"IS_EXECUTE\":\"1\",\"OBJECT_DEVICE_IP\":\"10.252.87.77\",\"SESSION_TYPE\":\"2\",\"ORI_GATHER_TIME\":\"2020-09-17 22:37:41.974\",\"PROVINCE_SOURCE_NAME\":\"\\\\u5317\\\\u4EAC\",\"OPERATE_CMD\":\"ssh_fxp_write\",\"RESOURCE_CODE\":\"2\",\"SUB_ACCOUNT_NAME\":\"kd_tanyf\",\"CLIENT_ADDRESS\":\"10.255.185.32\",\"DETAILS_LOG_ID\":\"7768d0a3ebcd4d078da1bb333471eb06\",\"PROTOCOL\":\"SFTP\",\"IDENTITY_NAME\":\"4AFortLog22\",\"CMD_NO\":\"4812\",\"IDR_CREATION_TIME\":\"2020-09-17 22:37:41\",\"OBJECT_DEVICE_PORT\":\"22\",\"OPERATE_OBJ_DIR\":\"//\",\"OPERATE_RESULT\":\"1\",\"SESSION_ID\":\"4fb233173fe44a1b8ace59da33952f0e\",\"OBJ_FILES\":\"/home/kd_tanyf/AnHui/Reflection/anhui_reflection_gpu_v3.tar.gzad\"}";
//        producer.send(msg);
        for (int i = 0; i < 10; i++) {
//            Thread.sleep(1000);
            producer.send(i+""+"~");
            System.out.println(i+""+"~");
        }

        producer.close();
        pulsarClient.close();
    }
}
